#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
using namespace std;

long long a, b, p;

long long quickpow(long long x, long long y, long long z)
{
    long long ans = 1, base = x;
    while (y > 0)
    {
        if (y & 1)
        {
            ans *= base;
            ans %= z;
        }
        base *= base;
        base %= z;
        y >>= 1;
    }
    return ans;
}

int main()
{
    cin >> a >> b >> p;
    long long ans = quickpow(a, b, p);
    cout << a << "^" << b << " mod " << p << "=" << ans << endl;
    //system("pause");
    return 0;
}
